<script setup>
import { ref, onMounted } from 'vue';

// 导入图片
import explore1 from '@/assets/home/explore1.jpg'
import explore2 from '@/assets/home/explore2.jpg'
import explore4 from '@/assets/home/explore4.jpg'
import explore5 from '@/assets/home/explore5.jpg'

const activeTab = ref('visa');
const isVisible = ref(false);
const sectionRef = ref(null);

const destinations = [
  { 
    id: 1, 
    name: '故宫', 
    image: explore1,
    description: '世界上现存规模最大的古代宫殿建筑群'
  },
  { 
    id: 2, 
    name: '外滩', 
    image: explore2,
    description: '上海最著名的地标之一，万国建筑博览群'
  },
  { 
    id: 3, 
    name: '橘子洲', 
    image: explore4,
    description: '湘江中的诗意绿洲，毛泽东笔下的秀丽画卷'
  },
  { 
    id: 4, 
    name: '重庆洪崖洞', 
    image: explore5,
    description: '山城夜景的璀璨明珠，巴渝文化的精髓'
  }
];

const setActiveTab = (tab) => {
  activeTab.value = tab;
};

onMounted(() => {
  const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        isVisible.value = true;
        observer.disconnect();
      }
    });
  }, { threshold: 0.2 });
  
  if (sectionRef.value) {
    observer.observe(sectionRef.value);
  }
});
</script>

<template>
  <section ref="sectionRef" class="trip-planner-section">
    <div class="trip-planner-container">
      <h2 class="section-title" :class="{ 'animate': isVisible }">3 steps for the perfect trip</h2>
      
      <p class="section-description" :class="{ 'animate': isVisible }">
        只需站稳入旅行偏好，如神秘历史古迹、自然风光，或热爱美食体验，再设定旅行时间、预算等。
        AI 智能综合海量数据，精准规划每日行程，游玩景点安排、交通路线与用餐住宿建议。
      </p>
      
      <div class="trip-tabs" :class="{ 'animate': isVisible }">
        <div class="tab-container">
          <div class="tab">
            <div class="tab-icon">🛂</div>
            <div class="tab-content">
              <h3>政策</h3>
              <p>Where are you going?</p>
            </div>
          </div>
          
          <div class="tab">
            <div class="tab-icon">📅</div>
            <div class="tab-content">
              <h3>日程</h3>
              <p>Add Dates</p>
            </div>
          </div>
          
          <div class="tab">
            <div class="tab-icon">🚗</div>
            <div class="tab-content">
              <h3>交通</h3>
              <p>All Activity</p>
            </div>
          </div>
          
          <div class="tab">
            <div class="tab-icon">👤</div>
            <div class="tab-content">
              <h3>个人</h3>
              <p>Personal information</p>
            </div>
          </div>
        </div>
      </div>
      
      <div class="destinations-container" :class="{ 'animate': isVisible }">
        <div class="destinations-grid">
          <div 
            v-for="(destination, index) in destinations" 
            :key="destination.id"
            class="destination-card"
            :style="{ 
              animationDelay: `${index * 0.15}s`,
              backgroundImage: `url(${destination.image})`
            }"
            :class="{ 'animate': isVisible }"
          >
            <div class="destination-content">
              <h3 class="destination-name">{{ destination.name }}</h3>
              <p class="destination-desc">{{ destination.description }}</p>
              <button class="destination-btn">查看详情</button>
            </div>
          </div>
        </div>
      </div>
      
      <div class="view-more-container" :class="{ 'animate': isVisible }">
        <button class="view-more-btn">查看更多</button>
      </div>
    </div>
  </section>
</template>

<style scoped>
.trip-planner-section {
  width: 100%;
  height: 1096px;
  background-color: #1a1f3d;
  background-image: url('@/assets/tp-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  padding: 80px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.trip-planner-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-title {
  font-size: 3rem;
  color: #00C389;
  text-align: center;
  margin-bottom: 40px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease;
}

.section-title.animate {
  opacity: 1;
  transform: translateY(0);
}

.section-description {
  max-width: 800px;
  text-align: center;
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 60px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease 0.2s;
}

.section-description.animate {
  opacity: 1;
  transform: translateY(0);
}

.trip-tabs {
  width: 100%;
  max-width: 1000px;
  margin-bottom: 80px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease 0.4s;
}

.trip-tabs.animate {
  opacity: 1;
  transform: translateY(0);
}

.tab-container {
  display: flex;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab {
  flex: 1;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.tab:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 20%;
  height: 60%;
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.tab:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.tab-icon {
  font-size: 24px;
  opacity: 0.9;
}

.tab-content {
  text-align: left;
}

.tab h3 {
  font-size: 1.1rem;
  color: #ffffff;
  margin-bottom: 4px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tab p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.tab:hover h3 {
  transform: translateY(-1px);
}

.tab:hover p {
  color: rgba(255, 255, 255, 0.9);
}

.destinations-container {
  width: 100%;
  margin-bottom: 40px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease 0.6s;
}

.destinations-container.animate {
  opacity: 1;
  transform: translateY(0);
}

.destinations-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.destination-card {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0;
  transform: translateY(30px);
}

.destination-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.7));
  z-index: 1;
}

.destination-content {
  position: relative;
  z-index: 2;
}

.destination-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  margin: 8px 0 15px;
  line-height: 1.4;
}

.destination-card.animate {
  animation: fadeInUp 0.8s forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.destination-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.destination-name {
  color: #ffffff;
  font-size: 1.5rem;
  margin-bottom: 15px;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.destination-btn {
  background-color: #ffffff;
  color: #333;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 0.9rem;
  cursor: pointer;
  width: fit-content;
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
  overflow: hidden;
}

.destination-btn:hover {
  background-color: #00C389;
  color: white;
  transform: translateY(-2px);
}

.destination-btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.7s ease;
}

.destination-btn:hover:before {
  left: 100%;
}

.view-more-container {
  margin-top: 40px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease 0.8s;
}

.view-more-container.animate {
  opacity: 1;
  transform: translateY(0);
}

.view-more-btn {
  background-color: transparent;
  color: #ffffff;
  border: 1px solid #ffffff;
  padding: 12px 30px;
  border-radius: 30px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.view-more-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.view-more-btn:after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: -100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.7s ease;
}

.view-more-btn:hover:after {
  left: 100%;
}

/* 响应式样式 */
@media (max-width: 1400px) {
  .trip-planner-section {
    height: auto;
  }
  
  .section-title {
    font-size: 2.5rem;
  }
  
  .destinations-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 992px) {
  .destinations-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .section-title {
    font-size: 2rem;
  }
  
  .section-description {
    font-size: 1rem;
  }
}

@media (max-width: 768px) {
  .tab {
    padding: 16px 12px;
    flex-direction: column;
    gap: 8px;
  }
  
  .tab-content {
    text-align: center;
  }
  
  .tab h3 {
    font-size: 0.9rem;
  }
  
  .tab p {
    font-size: 0.75rem;
  }
  
  .tab-icon {
    font-size: 20px;
  }
  
  .destinations-grid {
    grid-template-columns: 1fr;
  }
  
  .section-title {
    font-size: 1.8rem;
  }
}

@media (max-width: 576px) {
  .trip-planner-section {
    padding: 50px 0;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
  
  .section-description {
    font-size: 0.9rem;
  }
  
  .tab-container {
    flex-direction: column;
  }
  
  .tab {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
  }
  
  .tab:not(:last-child)::after {
    right: 10%;
    top: auto;
    bottom: 0;
    width: 80%;
    height: 1px;
  }
  
  .tab-content {
    text-align: left;
  }
}
</style> 